<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>axios</title>
</head>
<body>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script>
        // 省份数组
        let previnces = []
        async function getPrevinces(){
            //获取省份
            let {data:data1} = await axios.get('./data/city.json')
            previnces = data1.filter(r=>r.pid===0)
            //获取城市
            let {data:data2} = await axios.get('./data/city.json')
            previnces.forEach(async c=>{
                c.citys = data2.filter(r=>r.pid===c.id)
                //获取区县
                let {data:data3} = await axios.get('./data/city.json')
                c.citys.forEach(d=>{
                    d.districts = data3.filter(e=>e.pid===d.id)
                })
            })

            console.log(previnces);
        } 
        getPrevinces()
        
        
    </script>
</body>
</html>